package cn.byapps.hw.controller;

import cn.byapps.hw.entity.Cron;
import cn.byapps.hw.service.CronService;
import cn.byapps.hw.vo.VueData;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/cron")
public class CronController {

    @Resource
    private CronService cronService;

    @PutMapping
    public VueData add(@RequestBody Cron cron) {
        cronService.add(cron);
        return new VueData();
    }

    @PutMapping("/update")
    public VueData update(@RequestBody Cron cron) {
        cronService.update(cron);
        return new VueData();
    }

    @GetMapping
    public Cron getById(Integer id) {
        return cronService.getById(id);
    }
}
